package com.foredu.fiqs.persist.hibernate;

import java.util.List;

import com.foredu.fiqs.domain.Teacher;
import com.foredu.fiqs.persist.ITeacherDao;

public class HibernateTeacherDao extends HibernateAbstractDao<Teacher, Integer>
		implements ITeacherDao {

	private static final long serialVersionUID = 1L;

	public HibernateTeacherDao() {
		super(Teacher.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Teacher findTeacherByTeachId(String teachId) {
		List<Teacher> teachList = this.getHibernateTemplate().find("from Teacher t where t.teachId = ?", teachId);
		Teacher teacher = null;
		if (teachList != null && teachList.size() > 0) {
			teacher = teachList.get(0);
		}
		return teacher;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Teacher> findTeacherOfDept(int deptId) {
		return this.getHibernateTemplate().find("from Teacher t where t.dept.id = ? order by t.username", deptId);
	}

}
